<?php
/**
 * Frontend class of component WFilesystem
 * @package WFilesystem
 */
require_once 'WKernel/App.php';
require_once 'WKernel/Component.php';
require_once 'WNavigator/Map.php';

class WN_Component extends WK_Component {
	const NAME = 'WNavigator';	
	private static $_INSTANCE;
	
	private $map;
	
	private function __construct($config){
		$this->map = new WN_Map(@$config['working_dir'], @$config['format'] ? $config['format'] : 'XML');
	}	
	
	public static function getInstance($config){
		if(!self::$_INSTANCE)
			self::$_INSTANCE = new self ($config);
		return self::$_INSTANCE;
	}
	
	public function getMap(){
		return $this->map;
	}
	
	public function getCommand($name, $params = array()){
		$command_class = 'WN_Cmd_' . $name;
		$command_file  = self::NAME . '/Commands/' . $name . '.php';
		return $this->getCmdInstance($name, $command_class, $command_file, $params);
	}
}
WK_App::registerComponent(WN_Component::NAME, 'WN_Component');